package cn.rkylin.oms.goods.vo;

import java.util.List;

import cn.rkylin.oms.goods.domain.GoodsSku;

/**
 * 系统规格值对象，用于满足前台展示、系统间交互的需要
 *
 * @author wangxing
 * @version 1.0.0
 * @created 2017-7-5
 */
public class GoodsSkuVO extends GoodsSku {
    /**
     * 序列化id
     */
    private static final long serialVersionUID = 1197685576993484879L;

    /**
     * 状态定义
     */
    private static final String GIFTS_CHK = "<input id=\"chkGifts\" name=\"chkGifts\" type=\"checkbox\" />%s</input>";
    private static final String VIRT_CHK = "<input id=\"chkVirt\" name=\"chkVirt\" type=\"checkbox\" />%s</input>";
    private static final String SKUID_CHK = "<input id=\"\" name=\"selectSkuId\" type=\"checkbox\" goodsskuid=\"%s\" goodsCode=\"%s\" goodsName=\"%s\" skuCode=\"%s\" skuName=\"%s\" goodsId=\"%s\" /></input>";

    private List<String> listBar;
    private List<String> listBarId;

    private String goodsSkuIdChk;
    
    /**
     * 允许赠品复选框扩展
     */
    private String giftsShow;
    
    /**
     * 虚拟商品复选框扩展
     */
    private String virtShow;
    
    /**
     * 允许赠品复选框扩展
     */
    private String giftsChk;
    
    /**
     * 虚拟商品复选框扩展
     */
    private String virtChk;
    
    /**
     * 搜索条件
     */
    private String searchCondition;

    /**
     * orderBy子句
     */
    private String orderBy;
    
    /**
     * 用于查询项目下的sku
     */
    private String prjId;

    public List<String> getListBar() {
        return listBar;
    }

    public void setListBar(List<String> listBar) {
        this.listBar = listBar;
    }

    public List<String> getListBarId() {
        return listBarId;
    }

    public void setListBarId(List<String> listBarId) {
        this.listBarId = listBarId;
    }

    public String getGoodsSkuIdChk() {
        return String.format(SKUID_CHK, this.getSkuId(), this.getGoodsCode(), this.getGoodsName(), this.getSkuCode(), this.getSkuName(),
                this.getGoodsId()).toString();
    }

    public String getGiftsChk() {
        return this.giftsChk;
    }

    public void setGiftsChk(String giftsChk) {
        this.giftsChk = String.format(GIFTS_CHK, "").toString();
    }

    public String getVirtShow() {
        return "y".equals(this.getVirtYn()) ? "是" : "否";
    }

    public void setVirtShow(String virtShow) {
        this.virtShow = virtShow;
    }

    public String getGiftsShow() {
        return "y".equals(this.getGiftsYn()) ? "是" : "否";
    }

    public void setGiftsShow(String giftsShow) {
        this.giftsShow = giftsShow;
    }

    public String getVirtChk() {
        return this.virtChk;
    }

    public void setVirtChk(String virtChk) {
        this.virtChk = String.format(VIRT_CHK, "").toString();
    }

    public String getOrderBy() {
        // 此字段需要防止sql注入
        return orderBy == null ? null : orderBy.replaceAll(".*([';]+|(--)+).*", " ");
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }

    public String getSearchCondition() {
        return searchCondition;
    }

    public void setSearchCondition(String searchCondition) {
        this.searchCondition = searchCondition;
    }

    public String getPrjId() {
        return prjId;
    }

    public void setPrjId(String prjId) {
        this.prjId = prjId;
    }
    
}